package com.me.mygdxgame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;

public class Mario {
	
	
	public static final int State_Move=0;
	public static final int State_Jump=1;
	public static final int State_Stop=4;
	public static final int State_Move_RIGHT=2;
	public static final int State_Move_LEFT=3;

	public Body jumper;
	public static final float PIXELS_PER_METER = 60f;
	public int W=23,H=40;
	public int State;
	public int State_Pernas,State_Tronco,Last_State_Pernas,direction;
	public float StateTime;

	

	public Mario( World world, int x, int y){
		LoadBody(world,x,y);
	}
	
	
	protected void LoadBody(World world,int x,int y){
		
		
		BodyDef jumperBodyDef = new BodyDef();
		jumperBodyDef.type = BodyDef.BodyType.DynamicBody;
		jumperBodyDef.position.set(x, y);

		jumper = world.createBody(jumperBodyDef);

		/**
		 * Boxes are defined by their "half width" and "half height", hence the
		 * 2 multiplier.
		 */
		PolygonShape jumperShape = new PolygonShape();
		jumperShape.setAsBox(23f / (2 * PIXELS_PER_METER),
				34f / (2 * PIXELS_PER_METER));

		/**
		 * The character should not ever spin around on impact.
		 */
		jumper.setFixedRotation(true);

		/**
		 * The density of the jumper, 70, was found experimentally. Play with
		 * the number and watch how the character moves faster or slower.
		 * 
		 * The linear damping was also found the same way.
		 */
		jumper.createFixture(jumperShape, 73);
		jumperShape.dispose();

		jumper.setLinearVelocity(new Vector2(0.0f, 0.0f));
		jumper.setLinearDamping(2.5f);
		
	}
	
	
public void Update(float delta, int State_Actual){
		
		verifica_mudanca_estado(State_Actual);
		
		if(State_Actual==State_Stop)
			direction=Last_State_Pernas;
		
		State_Pernas=State_Actual;
		
		StateTime+=delta;
		
	}
	
	
	
	public  void verifica_mudanca_estado(int State_Actual){
		
		if(State_Actual!=State_Pernas){
			Last_State_Pernas=State_Pernas;
			StateTime=0;
			
		}
	}
	
	
	
}
